package com.tepth.maintenancesystem.adapter;

import android.content.Context;

import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;
import com.tepth.maintenancesystem.R;
import com.tepth.maintenancesystem.bean.VehicleMaintain;

import java.util.List;

/**
 * Created by LHQ on 2016/11/28.
 */

public class MaintainAdapter extends SuperBaseAdapter<VehicleMaintain> {

    public MaintainAdapter(Context context, List<VehicleMaintain> data) {
        super(context, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, VehicleMaintain item, int position) {
        holder.setAppCompatTextView(R.id.actv_vehiclenumber, item.getVehicleNumber());
        holder.setAppCompatTextView(R.id.actv_vehicleline, item.getRouteName());
        holder.setAppCompatTextView(R.id.actv_vehicletime, item.getPlanStartTime() + "-" + item.getPlanEndTime());
        if (item.getWorkStatusCode().equals("FinishWork") || item.getWorkStatusCode().equals("CompletedWork")) {//完成
            holder.setAppCompatImageView(R.id.vehicle_img, R.drawable.vehicle_green);
            holder.setAppCompatImageView(R.id.vehicle_img_text, R.drawable.done_text);
            holder.setVisible(R.id.vehicle_img_readywork,false);
        } else if (item.getWorkStatusCode().equals("UnderWork")) {//作业中
            holder.setAppCompatImageView(R.id.vehicle_img, R.drawable.vehicle_red);
            holder.setAppCompatImageView(R.id.vehicle_img_text, R.drawable.doing_text);
            holder.setVisible(R.id.vehicle_img_readywork,false);
        } else {//FinishPlan 未开始
            if(item.getWorkStatusCode().equals("ReadyWork")){
                holder.setVisible(R.id.vehicle_img_readywork,true);
            }else{
                holder.setVisible(R.id.vehicle_img_readywork,false);
            }
            holder.setAppCompatImageView(R.id.vehicle_img, R.drawable.vehicle_yellow);
            holder.setAppCompatImageView(R.id.vehicle_img_text, R.drawable.ready_text);
        }
    }

    @Override
    protected int getItemViewLayoutId(int position, VehicleMaintain item) {
        return R.layout.vehiclemaintain_item;
    }

}
